1. Field of the Invention
The invention relates to an image processing device and a storage medium storing an image processing program, and more specifically to an image processing device and a storage medium storing an image processing program that performs a Retinex process on an image.
2. Description of the Related Art
When taking a photograph of a subject under backlit conditions, e.g. against the sun, the image of the subject portion is an indistinct backlit image with low lightness and contrast, making it difficult to make out details of the subject. Image processing is performed to improve the quality of these backlit images, as well as images suffering in quality due to overexposure, underexposure, blurring due to jiggling when capturing the image, noise, insufficient light, and the like, in order to improve lightness and contrast in the image. One method used in conventional image processing is a Retinex process.
The Retinex process preserves the input image data for high-quality regions and improves the image quality primarily in low-quality regions. The Retinex process uses Gaussian filters for calibrating pixel data in the original image to values reflecting data of surrounding pixels, calculates reference component data for the original image from the natural logarithm of the calibrated pixel data, and calculates luminance component data by dividing pixel data of the original image by pixel components of the original image. Specifically, this process divides the original image into reference components and luminance components. Next, a process is performed to calibrate the brightness and level (contrast) of the luminance component through gamma correction or the like and subsequently generates improved image data for the original image in backlit portions and the like by combining the calibrated luminance components with the reference components. The reference component is found by normalizing a reflectance R(x, y).
U.S. Pat. No. 6,885,482 (corresponding to Japanese Patent Application Publication No. 2001-69525) discloses a method of converting RGB values to a color space configured of a luminance component and chromatic components, such as YCbCr or YIQ, performing the Retinex process only on the luminance component Y, while maintaining the chromatic components, and converting the values back to RGB. Calibrating only the luminance component (i.e. not calibrating the chromatic components) prevents an upset in the color balance and a shift in color. Further, since the Retinex process is performed only on the luminance component, this method requires fewer calculations than a method for performing the Retinex process on each RGB plane and, hence, can complete the process quicker. Further, less storage space is required for normalizing reflectance R(x, y) values since only the luminance value is stored, rather than each RGB value.
U.S. Patent Application Publication No. 2004/0091164 (corresponding to Japanese Patent No. 3,731,577) discloses a method for improving the processing speed in the Retinex process. This method forms a reduced image (low-resolution image) from the original image using the average pixel method or the like, forms a peripheral average luminance image (blurred image) by finding the surrounding average luminance for each pixel in the reduced image, forms a Retinex processed image from the original image and an image produced by expanding the blurred image, and forms an output image from the original image and the Retinex processed image.